home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
dll_gen
/
winfox
/
dplibobj.ba_
/
dplibobj.ba
Wrap
Text File
|
1995-01-31
|
17KB
|
453 lines
'DPLIBOBJ.BAS
'1/15/95
'Digital PowerTOOLS Library for Objects
'Copyright ⌐ 1995 by Digital PowerTOOLS
'these functions and subroutines are intended ONLY for use
'in your application; you are not authorized to distribute
'this source code
Type ObjRect
Left As Integer
Top As Integer
right As Integer
bottom As Integer
End Type
Declare Sub GetWindowRect Lib "User" (ByVal hWnd%, lpRect As ObjRect)
Declare Function GetDC% Lib "User" (ByVal hWnd%)
Declare Function ReleaseDC% Lib "User" (ByVal hWnd%, ByVal hDC%)
Declare Sub Rectangle Lib "GDI" (ByVal hDC%, ByVal X1%, ByVal Y1%, ByVal X2%, ByVal Y2%)
Declare Function CreateSolidBrush% Lib "GDI" (ByVal crColor&)
Declare Function SelectObject% Lib "GDI" (ByVal hDC%, ByVal hObject%)
Declare Sub DeleteObject Lib "GDI" (ByVal hObject%)
Declare Function FillRect Lib "User" (ByVal hDC As Integer, lpRect As ObjRect, ByVal hBrush As Integer) As Integer
Declare Function AltDeleteObject Lib "GDI" Alias "DeleteObject" (ByVal hObject As Integer) As Integer
Sub DoControl3D (Obj As Control, Style, thick)
'draws 3D shadows effects around a control
'Style is either "sunken" or "raised"
'use this function in the Paint event of the form
If thick <= 0 Then thick = 1
If thick > 8 Then thick = 8
OldMode = Obj.Parent.ScaleMode
OldWidth = Obj.Parent.DrawWidth
Obj.Parent.ScaleMode = 3
Obj.Parent.DrawWidth = 1
ObjHeight = Obj.Height
ObjWidth = Obj.Width
ObjLeft = Obj.Left
ObjTop = Obj.Top
Select Case LCase$(Style)
Case "sunken":
TLshade = QBColor(8)
BRshade = QBColor(15)
Case "raised":
TLshade = QBColor(15)
BRshade = QBColor(8)
End Select
For i = 1 To thick
CurLeft = ObjLeft - i
CurTop = ObjTop - i
CurWide = ObjWidth + (i * 2) - 1
CurHigh = ObjHeight + (i * 2) - 1
Obj.Parent.Line (CurLeft, CurTop)-Step(CurWide, 0), TLshade
Obj.Parent.Line -Step(0, CurHigh), BRshade
Obj.Parent.Line -Step(-CurWide, 0), BRshade
Obj.Parent.Line -Step(0, -CurHigh), TLshade
Next i
If thick > 2 Then
CurLeft = ObjLeft - thick - 1
CurTop = ObjTop - thick - 1
CurWide = ObjWidth + ((thick + 1) * 2) - 1
CurHigh = ObjHeight + ((thick + 1) * 2) - 1
Obj.Parent.Line (CurLeft, CurTop)-Step(CurWide, 0), QBColor(0)
Obj.Parent.Line -Step(0, CurHigh), QBColor(0)
Obj.Parent.Line -Step(-CurWide, 0), QBColor(0)
Obj.Parent.Line -Step(0, -CurHigh), QBColor(0)
End If
Obj.Parent.ScaleMode = OldMode
Obj.Parent.DrawWidth = OldWidth
End Sub
Sub DoEtchedFrame (Obj As PictureBox, TextMsg, Just, ColorVal&, TextStyle, ObjStyle)
'makes a PictureBox look like a stylized Frame (GroupBox)
'PictureBoxes can contain option buttons
'Just is "left", "right", or "center"
'TextStyle is either "sunken" or "raised"
'ObjStyle is either "sunken" or "raised"
'use this function in the Paint event of the form
Obj.BorderStyle = 0
Obj.AutoRedraw = True
OldScaleMode = Obj.ScaleMode
Obj.ScaleMode = 1
OldDrawMode = Obj.DrawWidth
Obj.DrawWidth = 1
TxLen% = Obj.TextWidth(TextMsg)
Obj.ForeColor = ColorVal
Cur1Left% = Obj.ScaleLeft + 15
Cur1Top% = Obj.ScaleTop + (Obj.TextHeight("A") / 2)
Cur1Wide% = Obj.ScaleWidth - 30
Cur1High% = (Obj.ScaleHeight - 30)
Cur2Left% = Obj.ScaleLeft
Cur2Top% = Obj.ScaleTop + ((Obj.TextHeight("A") / 2) - 10)
Cur2Wide% = Obj.ScaleWidth - 15
Cur2High% = (Obj.ScaleHeight - 10)
Select Case LCase$(Just)
Case "left"
Left1Start% = Cur1Left%
Left1End% = 120
Right1Start% = Left1End% + TxLen% + 240
Right1End% = Cur1Wide%
Left2Start% = Cur2Left%
Left2End% = 110
Right2Start% = Left2End% + TxLen% + 240
Right2End% = Cur2Wide%
Xpos% = 240
Ypos% = 0
Case "right"
Left1Start% = Cur1Left%
Left1End% = (Cur1Wide% - TxLen%) - 350
Right1Start% = Cur1Wide% - 120
Right1End% = Cur1Wide%
Left2Start% = Cur2Left%
Left2End% = (Cur2Wide% - TxLen%) - 350
Right2Start% = Cur2Wide% - 130
Right2End% = Cur2Wide%
Xpos% = Left1End% + 120
Ypos% = 0
Case "center"
Left1Start% = Cur1Left%
Left1End% = (Cur1Wide% - (TxLen% + 240)) / 2
Right1Start% = Cur1Wide% - Left1End%
Right1End% = Cur1Wide%
Left2Start% = Cur2Left%
Left2End% = (Cur2Wide% - (TxLen% + 240)) / 2
Right2Start% = Cur2Wide% - Left2End%
Right2End% = Cur2Wide%
Xpos% = Left1End% + 120
Ypos% = 0
End Select
If LCase$(TextStyle) = "sunken" Then
Obj.CurrentX = Xpos% + 15
Obj.CurrentY = Ypos% + 15
Obj.ForeColor = QBColor(8)
Obj.Print TextMsg
End If
If LCase$(TextStyle) = "raised" Then
Obj.CurrentX = Xpos% - 15
Obj.CurrentY = Ypos% - 15
Obj.ForeColor = QBColor(15)
Obj.Print TextMsg
Obj.CurrentX = Xpos% + 15
Obj.CurrentY = Ypos% + 15
Obj.ForeColor = QBColor(8)
Obj.Print TextMsg
End If
Obj.CurrentX = Xpos%
Obj.CurrentY = Ypos%
Obj.ForeColor = ColorVal
Obj.Print TextMsg
Select Case LCase$(ObjStyle)
Case "sunken"
TLshade = QBColor(15)
BRshade = QBColor(8)
Case "raised"
TLshade = QBColor(8)
BRshade = QBColor(15)
End Select
Obj.Line (Left1Start%, Cur1Top%)-(Left1End%, Cur1Top%), TLshade
Obj.Line (Right1Start%, Cur1Top%)-(Right1End%, Cur1Top%), TLshade
Obj.Line (Right1End%, Cur1Top%)-(Right1End%, Cur1High%), BRshade
Obj.Line (Right1End%, Cur1High%)-(Left1Start%, Cur1High%), BRshade
Obj.Line (Left1Start%, Cur1High%)-(Left1Start%, Cur1Top%), TLshade
Obj.Line (Left2Start%, Cur2Top%)-(Left2End%, Cur2Top%), BRshade
Obj.Line (Right2Start%, Cur2Top%)-(Right2End%, Cur2Top%), BRshade
Obj.Line (Right2End%, Cur2Top%)-(Right2End%, Cur2High%), TLshade
Obj.Line (Right2End%, Cur2High%)-(Left2Start%, Cur2High%), TLshade
Obj.Line (Left2Start%, Cur2High%)-(Left2Start%, Cur2Top%), BRshade
Obj.ScaleMode = OldScaleMode
Obj.DrawWidth = OldDrawMode
Obj.AutoRedraw = False
End Sub
Sub DoForm3D (TheForm As Form, Style, thick, Distance)
'draws 3D shadow effects on a form
'can be called with different values for a variety of effects
'Style is either "sunken" or "raised"
'use this function in the Paint event of the form
If thick <= 0 Then thick = 1
If thick > 8 Then thick = 8
If Distance < 0 Then Distance = 0
If Distance > 8 Then Distance = 8
OldMode = TheForm.ScaleMode
OldWidth = TheForm.DrawWidth
TheForm.ScaleMode = 3
TheForm.DrawWidth = 1
FormHeight = TheForm.ScaleHeight
FormWidth = TheForm.ScaleWidth
FormLeft = TheForm.ScaleLeft
FormTop = TheForm.ScaleTop
Select Case LCase$(Style)
Case "sunken":
TLshade = QBColor(8)
BRshade = QBColor(15)
Case "raised":
TLshade = QBColor(15)
BRshade = QBColor(8)
End Select
Select Case TheForm.BorderStyle
Case 0:
OLshade = QBColor(0)
TheForm.Line (0, 0)-(FormWidth, 0), OLshade
TheForm.Line (0, 0)-(0, FormHeight), OLshade
TheForm.Line (FormWidth - 1, 0)-(FormWidth - 1, FormHeight + 1), OLshade
TheForm.Line (0, FormHeight - 1)-(FormWidth, FormHeight - 1), OLshade
For i = 1 To thick
CurLeft = FormLeft + i + Distance
CurTop = FormTop + i + Distance
CurWide = FormWidth - (i + Distance) * 2 - 1
CurHigh = FormHeight - (i + Distance) * 2 - 1
TheForm.Line (CurLeft, CurTop)-Step(CurWide, 0), TLshade
TheForm.Line -Step(0, CurHigh), BRshade
TheForm.Line -Step(-CurWide, 0), BRshade
TheForm.Line -Step(0, -CurHigh), TLshade
Next i
Case 1 To 3:
If Thickness = 1 Then
TheForm.Line (thick, thick)-(FormWidth - thick, thick), TLshade
TheForm.Line (thick, thick)-(thick, FormHeight - thick), TLshade
TheForm.Line (FormWidth - thick, thick)-(FormWidth - thick, FormHeight - thick + 1), BRshade
TheForm.Line (thick, FormHeight - thick)-(FormWidth - thick, FormHeight - thick), BRshade
Else
For i = 1 To thick
CurLeft = FormLeft + i - 1 + Distance
CurTop = FormTop + i - 1 + Distance
CurWide = FormWidth - (i + Distance) * 2 + 1
CurHigh = FormHeight - (i + Distance) * 2 + 1
TheForm.Line (CurLeft, CurTop)-Step(CurWide, 0), TLshade
TheForm.Line -Step(0, CurHigh), BRshade
TheForm.Line -Step(-CurWide, 0), BRshade
TheForm.Line -Step(0, -CurHigh), TLshade
Next i
End If
End Select
TheForm.ScaleMode = OldMode
TheForm.DrawWidth = OldWidth
End Sub
Sub DoPicture3D (ThePB As PictureBox, Style, thick, Distance)
'draws 3D shadow effects on a PictureBox
'can be called with different values for a variety of effects
'Style is either "sunken" or "raised"
'great for VB coded statusbars, etc.
'use this function in the Paint event of the PictureBox
If thick <= 0 Then thick = 1
If thick > 8 Then thick = 8
If Distance < 0 Then Distance = 0
If Distance > 8 Then Distance = 8
OldMode = ThePB.ScaleMode
OldWidth = ThePB.DrawWidth
ThePB.ScaleMode = 3
ThePB.DrawWidth = 1
FormHeight = ThePB.ScaleHeight
FormWidth = ThePB.ScaleWidth
FormLeft = ThePB.ScaleLeft
FormTop = ThePB.ScaleTop
Select Case LCase$(Style)
Case "sunken":
TLshade = QBColor(8)
BRshade = QBColor(15)
Case "raised":
TLshade = QBColor(15)
BRshade = QBColor(8)
End Select
Select Case ThePB.BorderStyle
Case 0:
OLshade = QBColor(0)
ThePB.Line (0, 0)-(FormWidth, 0), OLshade
ThePB.Line (0, 0)-(0, FormHeight), OLshade
ThePB.Line (FormWidth - 1, 0)-(FormWidth - 1, FormHeight + 1), OLshade
ThePB.Line (0, FormHeight - 1)-(FormWidth, FormHeight - 1), OLshade
For i = 1 To thick
CurLeft = FormLeft + i + Distance
CurTop = FormTop + i + Distance
CurWide = FormWidth - (i + Distance) * 2 - 1
CurHigh = FormHeight - (i + Distance) * 2 - 1
ThePB.Line (CurLeft, CurTop)-Step(CurWide, 0), TLshade
ThePB.Line -Step(0, CurHigh), BRshade
ThePB.Line -Step(-CurWide, 0), BRshade
ThePB.Line -Step(0, -CurHigh), TLshade
Next i
Case 1 To 3:
If Thickness = 1 Then
ThePB.Line (thick, thick)-(FormWidth - thick, thick), TLshade
ThePB.Line (thick, thick)-(thick, FormHeight - thick), TLshade
ThePB.Line (FormWidth - thick, thick)-(FormWidth - thick, FormHeight - thick + 1), BRshade
ThePB.Line (thick, FormHeight - thick)-(FormWidth - thick, FormHeight - thick), BRshade
Else
For i = 1 To thick
CurLeft = FormLeft + i - 1 + Distance
CurTop = FormTop + i - 1 + Distance
CurWide = FormWidth - (i + Distance) * 2 + 1
CurHigh = FormHeight - (i + Distance) * 2 + 1
ThePB.Line (CurLeft, CurTop)-Step(CurWide, 0), TLshade
ThePB.Line -Step(0, CurHigh), BRshade
ThePB.Line -Step(-CurWide, 0), BRshade
ThePB.Line -Step(0, -CurHigh), TLshade
Next i
End If
End Select
ThePB.ScaleMode = OldMode
ThePB.DrawWidth = OldWidth
End Sub
Sub FadeForm (TheForm As Form, FadeColor&, FadeDegree)
'draws a color-faded background on a form
'use this routine in the Paint event of a form
'FadeColor& is the starting color to use
' QBcolor(1) or WordColor("blue") is common
'FadeDegree is the amount of fading to implement
' 32 to 128 is normal; 64 is typical color fade
' the lower the value, the slower the fade
Dim StepInterval As Integer
Dim RetVal As Integer
Dim FillArea As ObjRect
OldMode% = TheForm.ScaleMode
TheForm.ScaleMode = 3
FormHeight% = TheForm.ScaleHeight
sections% = FadeDegree
StepInterval = FormHeight% \ sections%
Red% = GetColorValue("red", FadeColor)
Green% = GetColorValue("green", FadeColor)
Blue% = GetColorValue("blue", FadeColor)
FillArea.Left = 0
FillArea.right = TheForm.ScaleWidth
FillArea.Top = 0
FillArea.bottom = StepInterval
For x = 0 To sections%
hBrush% = CreateSolidBrush(RGB(Red%, Green%, Blue%))
RetVal = FillRect(TheForm.hDC, FillArea, hBrush%)
RetVal = AltDeleteObject(hBrush%)
If Red% <> 0 Then
Red% = Red% - 4: If Red% < 0 Then Red% = 0
End If
If Green% <> 0 Then
Green% = Green% - 4: If Green% < 0 Then Green% = 0
End If
If Blue% <> 0 Then
Blue% = Blue% - 4: If Blue% < 0 Then Blue% = 0
End If
FillArea.Top = FillArea.bottom
FillArea.bottom = FillArea.bottom + StepInterval + 1
Next
TheForm.ScaleMode = OldMode%
End Sub
Sub FormBLscreen (TheForm As Form)
If TheForm.WindowState = 0 Then
BotPos = Screen.Height - TheForm.Height
TheForm.Move (0), (BotPos)
End If
End Sub
Sub FormBRscreen (TheForm As Form)
If TheForm.WindowState = 0 Then
BotPos = Screen.Height - TheForm.Height
RightPos = Screen.Width - TheForm.Width
TheForm.Move (RightPos), (BotPos)
End If
End Sub
Sub FormCenterForm (TheForm As Form, MainForm As Form)
'centers one (nonMDIchild) form within another form
If TheForm.WindowState = 0 Then
TheForm.Move MainForm.Left + (MainForm.Width - TheForm.Width) / 2, MainForm.Top + (MainForm.Height - TheForm.Height) / 2
End If
End Sub
Sub FormCenterScreen (TheForm As Form)
'centers a form on the screen
'great for primary form and modal forms
If TheForm.WindowState = 0 Then
TheForm.Move (Screen.Width - TheForm.Width) / 2, (Screen.Height - TheForm.Height) / 2
End If
End Sub
Sub FormTLscreen (TheForm As Form)
If TheForm.WindowState = 0 Then TheForm.Move (0), (0)
End Sub
Sub FormTRscreen (TheForm As Form)
If TheForm.WindowState = 0 Then
RightPos = Screen.Width - TheForm.Width
TheForm.Move (RightPos), (0)
End If
End Sub
Sub ShowForm (TheForm As Form, Style, FillColor&, SpeedFactor)
'displays a form in stylized fashion
'set the form's color (in design mode) to the same value as FillColor&
'Style="CenterOut", "CenterDown", or "LeftDown"
'the higher the speed facter, the slower the dispay
' use 1 - 10 for best results
Dim FormRect As ObjRect
GetWindowRect TheForm.hWnd, FormRect
FullWidth = FormRect.right - FormRect.Left
FullHeight = FormRect.bottom - FormRect.Top
ScreenHDC% = GetDC(0)
hBrush% = CreateSolidBrush(FillColor)
OldBrushHndl% = SelectObject(ScreenHDC%, hBrush%)
speed = SpeedFactor * 25
For index = 1 To speed
xx% = FullWidth * (index / speed)
yy% = FullHeight * (index / speed)
Select Case LCase$(Style)
Case "center outward"
x% = FormRect.Left + (FullWidth - xx%) / 2
y% = FormRect.Top + (FullHeight - yy%) / 2
Case "center downward"
x% = FormRect.Left + (FullWidth - xx%) / 2
y% = FormRect.Top
Case "left downward"
x% = FormRect.Left
y% = FormRect.Top
End Select
Rectangle ScreenHDC%, x%, y%, x% + xx%, y% + yy%
Next index
ret% = ReleaseDC(0, ScreenHDC%)
DeleteObject (hBrush%)
TheForm.Visible = True
End Sub